#include <iostream>
#include <set>

using namespace std;

class Solution {
public:
    string reverseVowels(string s) {
        int begin = 0;
        int end = s.size() - 1;
        set<char> mySet = { 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U' };

        while (begin < end) {
            while ((begin < end) && (mySet.find(s[begin]) == mySet.end())) {
                ++begin;
            }
            while ((begin < end) && (mySet.find(s[end]) == mySet.end())) {
                --end;
            }
            if (begin < end) {
                swap(s[begin], s[end]);
                ++begin;
                --end;
            }


        }

        return s;
    }
};

int main()
{
    string str = "IceCreAm";
    Solution s;
    string ret = s.reverseVowels(str);
    cout << ret << endl;
    
    return 0;
}